-
-
Couldn't load subscription status.
- Fork 33.2k
gh-65865: Raise early errors for invalid help strings in argparse #124899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-65865: Raise early errors for invalid help strings in argparse #124899
Conversation
Since python/cpython#124899, argparse help strings are more strict, and will fail with invalid `%` format strings.
Since python/cpython#124899, argparse help strings are more strict, and will fail with invalid `%` format strings.
|
Just want to share that the new errors seems a bit cryptic. In Traceback (most recent call last):
File "/home/benchmarking/actions-runner/_work/benchmarking/benchmarking/cpython/Lib/argparse.py", line 1659, in _check_help
formatter._expand_help(action)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/benchmarking/actions-runner/_work/benchmarking/benchmarking/cpython/Lib/argparse.py", line 604, in _expand_help
return help_string % params
~~~~~~~~~~~~^~~~~~~~
TypeError: %o format: an integer is required, not dictThe issue was that the help string for one argument contained the phrase |
|
This is not specific to arparse. You get the same error message with pure printf-style error formatting: >>> '90% of' % {'a': 1}
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
'90% of' % {'a': 1}
~~~~~~~~~^~~~~~~~~~
TypeError: %o format: an integer is required, not dictPlease open a new issue if you have ideas how to improve this. In argparse, the full traceback refers also to the line in your code that adds an invalid help string, so get a guide where to search for error. |
Uh oh!
There was an error while loading. Please reload this page.